import math
import sys
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from heapq import heappush,heappop,heapify
import gc
sys.setrecursionlimit(20000)
def getList(val=0): if not val:return list(map(int,input().split()))
else:return list(map(str,input().split()))
def getTuple(val=0):
if not val:return map(int,input().split())
return map(str,input().split())
def printList(arr,pri=False):
if pri:print('ans',end=' ')
for i in arr:print(i,end=' ')
print()
def myCode():
n = int(input())
ans = []
arr = [0 for i in range(20)]
for __ in range(n):
count = int(input())
ddd = getList()
ind = 0
while count:
b = count%2
count = count>>1
if b:arr[ind]+=1
ind+=1
for i in range(19,-1,-1):
if arr[i]>1:
ans += ['1']*(i+1)
break
elif arr[i]==1:
ans.append('1')
else:ans.append('0')
print(int(''.join(ans),2))
for _ in range(int(input())):
myCode()
1353D - Constructing the Array | 1269C - Long Beautiful Integer |
1076A - Minimizing the String | 913C - Party Lemonade |
1313A - Fast Food Restaurant | 681A - A Good Contest |
1585F - Non-equal Neighbours | 747A - Display Size |
285A - Slightly Decreasing Permutations | 515C - Drazil and Factorial |
1151E - Number of Components | 1151F - Sonya and Informatics |
556A - Case of the Zeros and Ones | 867A - Between the Offices |
1569A - Balanced Substring | 260A - Adding Digits |
1698C - 3SUM Closure | 1029B - Creating the Contest |
1421A - XORwice | 1029A - Many Equal Substrings |
1675D - Vertical Paths | 1271C - Shawarma Tent |
805A - Fake NP | 1163A - Eating Soup |
787A - The Monster | 807A - Is it rated |
1096A - Find Divisible | 1430C - Numbers on Whiteboard |
1697B - Promo | 208D - Prizes Prizes more Prizes |